<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!----------------------- CSS ----------------------->
<link href="${pageContext.request.contextPath}/dwz/themes/default/style.css" rel="stylesheet" type="text/css" media="screen"/>
<link href="${pageContext.request.contextPath}/dwz/themes/css/core.css" rel="stylesheet" type="text/css" media="screen"/>
<link href="${pageContext.request.contextPath}/dwz/themes/css/print.css" rel="stylesheet" type="text/css" media="print"/>
<link href="${pageContext.request.contextPath}/dwz/uploadify/css/uploadify.css" rel="stylesheet" type="text/css" media="screen"/>
<!--[if IE]>
<link href="${pageContext.request.contextPath}/dwz/themes/css/ieHack.css" rel="stylesheet" type="text/css" media="screen"/>
<![endif]-->
<!--[if lte IE 9]>
<script src="${pageContext.request.contextPath}/dwz/js/speedup.js" type="text/javascript"></script>
<![endif]-->

<!----------------------- JS ----------------------->

<!-- JQuery -->
<script src="${pageContext.request.contextPath}/dwz/js/jquery-1.7.2.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/dwz/js/jquery.cookie.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/dwz/js/jquery.validate.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/dwz/js/jquery.bgiframe.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/dwz/js/dwz.min.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/dwz/js/dwz.regional.zh.js" type="text/javascript"></script>

<script src="${pageContext.request.contextPath}/dwz/xheditor/xheditor-1.1.12-zh-cn.min.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/dwz/js/dwz.database.js"	type="text/javascript"></script>
<script type="text/javascript">
$(function() {
	DWZ.init("${pageContext.request.contextPath}/dwz/dwz.frag.xml", {
		//loginUrl : "login_loginDialog.action",
		//loginTitle : "登录", // 弹出登录对话框
		loginUrl:"login_login.action",	// 跳到登录页面
		statusCode : {
			ok : 200,
			error : 300,
			timeout : 301
		}, //【可选】
		pageInfo : {
			pageNum : "pageNum",
			numPerPage : "numPerPage",
			orderField : "orderField",
			orderDirection : "orderDirection"
		}, //【可选】
		debug : false, // 调试模式 【true|false】
		callback : function() {
			initEnv();
			$("#themeList").theme({
				themeBase : "${pageContext.request.contextPath}/dwz/themes"
			}); // themeBase 相对于index页面的主题base路径
		}
	});
});

/**
 * 通用递归展示级联Tree方法
 * @param data json数据
 *        data 格式为：
 *        {'treeId':'treeId','pId':'pId','treeName':'treeName'}
 * @param pId       父级ID/code
 * @param url       点击树形节点转向URL，一般为xx.action
 * @param paramName 跳转URL所需传递参数名称，注意此参数值为treeId.
 * @param rel   跳转页面rel属性
 * @param params 其它传递参数  
 */
function getDWZTreeHTML(data, pId, url, paramName, rel,params) {
	var temp = "";
 	var tree;
	if (pId == "") {
		tree = '<ul class="tree treeFolder collapse">';
	} else {
		tree = '<ul>';
	}
	for ( var i in data) {
		if (data[i].pId == pId) {
			if(url==""){
				temp = "javascript:void(0);";
			}else{
				temp = url + "?" + paramName + "=" + data[i].treeId + params;
			} ;
			tree += "<li><a href='"+temp+"' ";
			if(url!=""){
				tree += " target='ajax' ";
			}
			tree += " rel='"+rel+"'>"
					+ data[i].treeName + "</a>";
			tree += getDWZTreeHTML(data, data[i].treeId, url, paramName, rel, params);
			tree += "</li>";
		}
	}
	return tree + "</ul>";
}
 
 function getDWZTreeHTML2(data, pId,tname) {
		var temp = "";
	 	var tree;
		if (pId == "") {
			tree = '<ul class="tree treeFolder treeCheck expand" oncheck="checkNode">';
		} else {
			tree = '<ul>';
		}
		for ( var i in data) {
			if (data[i].pId == pId) {
				tree += "<li><a  tname='"+tname+"' tvalue='"+data[i].treeId+"' > " + data[i].treeName + "</a>";
						
				tree += getDWZTreeHTML2(data, data[i].treeId,tname);
				tree += "</li>";
			}
		}
		return tree + "</ul>";
	}
 
 
 
 //学校查找带回回调函数，处理级联数据
 function scl_lookup_callback(sclId,gradId,clsId) {
 	var $scl = $("#"+sclId, navTab.getCurrentPanel());
 	$.post("grade_list.action", {
 		"sclId" : $scl.val()
 	}, function(data) {
 		var html = '';
 		for (var i = 0; i < data.length; i++) {
 			html += '<option value="'+data[i][0]+'">' + data[i][1]
 					+ '</option>';
 		}
 		var $ref = $("#"+gradId, navTab.getCurrentPanel());
 		var $refCombox = $ref.parents("div.combox:first");
 		$ref.html(html).insertAfter($refCombox);
 		$refCombox.remove();
 		$ref.combox();

 		var $cls = $("#"+clsId, navTab.getCurrentPanel());
 		var $clsCombox = $cls.parents("div.combox:first");
 		$cls.html("<option value=''>---请选择---</option>").insertAfter($clsCombox);
 		$clsCombox.remove();
 		$cls.combox();
 	}, "json");
 }
 
/** 扩展DWZ dialog利用页码分页 目前使用版本dwz有bug
  @param obj 选择页码的select框
  @param numPerPageId  页面From隐藏存储numPerPage的元素ID
  BUG描述：
  1.官方源码中 targetType 直接使用 dialog传值  即 targetType:dialog
  	这样会提示 Uncaught ReferenceError: dialog is not defined (dialog未定义) 
  	需要采用String方式传递该类型参数 即 targetType:'dialog'
  2.分页参数覆盖问题
           因dwz分页页面需要放置隐藏元素存储numPerPage值
           但是在使用dwzPageBreak函数时 select的选中的页码值会被隐藏值覆盖
           造成通过页码分页无效
*/
function dialogNumPaging(obj,numPerPageId){
	$("#"+numPerPageId, $.pdialog.getCurrent()).val(obj.value);      
	dwzPageBreak({targetType:'dialog', numPerPage:this.value});
}
</script>